﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SH.Common.CommonReturn;
using SH.Common.DataDictionary;
using SH.Multitenant.Application.IServices.IOperationLog;
using SH.Multitenant.Domain.RBAC;

namespace SH.Multitenant.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OperationLogController : ControllerBase
    {
        private readonly IOperationLogServices _operationLogServices;

        public OperationLogController(IOperationLogServices operationLogServices)
        {
            _operationLogServices = operationLogServices;
        }
        /// <summary>
        /// 获取操作模块
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetOperationModules()
        {
            var result = _operationLogServices.GetOperationModules();
            ApiResult<List<Dic>> apiResult = new ApiResult<List<Dic>>();
            apiResult.Success(result);
            return Ok(apiResult);
        }
        /// <summary>
        /// 多条件分页获取操作日志列表
        /// </summary>
        /// <param name="sDate"></param>
        /// <param name="eDate"></param>
        /// <param name="module"></param>
        /// <param name="operationName"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetOperationLogs(DateTime? sDate, DateTime? eDate, string? module, string? operationName, int pageSize, int pageIndex)
        {
            var result = await _operationLogServices.GetOperationLogs(sDate, eDate, module, operationName, pageSize, pageIndex);
            return Ok(result);
        }
    }
}
